package com.east.sng.service.impl;

import com.east.sng.dao.ChargeDao;
import com.east.sng.entity.param.ChargeParam;
import com.east.sng.entity.param.ChargeSearchParam;
import com.east.sng.entity.result.ChargeInfo;
import com.east.sng.service.ChargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author east
 * @date: 2021/1/3
 * @Description:
 **/
@Service
public class ChargeServiceImpl implements ChargeService {
    @Autowired
    private ChargeDao chargeDao;

    @Override
    public List<ChargeInfo> findCharges(ChargeSearchParam params) {
        return this.chargeDao.selectCharges(params);
    }

    @Override
    public List<Map<String, Object>> findChargeDatas(String startTime, String endTime) {
        return chargeDao.selectChargeDatas(startTime, endTime);
    }

    @Override
    public void addCharge(ChargeParam chargeInfo) {
        this.chargeDao.insertCharge(chargeInfo);
    }

    @Override
    public boolean removeCharge(Integer chargeId) {
        return this.chargeDao.deleteOrRecoverCharge(chargeId,1) > 0;
    }

    @Override
    public boolean recoverCharge(Integer chargeId) {
        return this.chargeDao.deleteOrRecoverCharge(chargeId,0)>0;
    }

    @Override
    public boolean batchRemoveCharges(List<Integer> chargeIds) {
        return this.chargeDao.batchDeleteOrRecoverCharges(chargeIds,1) > 0;
    }

    @Override
    public boolean batchRecoverCharges(List<Integer> chargeIds) {
        return this.chargeDao.batchDeleteOrRecoverCharges(chargeIds,0) > 0;
    }

    @Override
    public List<ChargeInfo> findChargeInfo(List<Integer> chargeIds) {
        return chargeDao.selectChargeInfo(chargeIds);
    }
}